<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>文档标题</title>
</head>
<body>

<h1>自动计数器：<span id="count">0</span></h1>
<button id="start">开始</button>
<button id="end">暂停</button>

<script>
  window.onload = function () {
    const start = document.getElementById("start");
    const end = document.getElementById("end");
    let interval;
    start.onclick = () => {
      start.disabled = true;
      end.disabled = false;
      interval = setInterval(() => {
        document.getElementById("count").innerText++;
      }, 1e3);
    };
    end.onclick = () => {
      start.disabled = false;
      end.disabled = true;
      interval ? clearInterval(interval) : undefined;
    };
    end.disabled = true;
  }
</script>
</body>
</html>
